package fiarproject;

import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class TestGameInput {
    String[] test1 = new String[7];
    String[] test2 = new String[7];
    String[] test3 = new String[7];
    String[] test4 = new String[7];
    String[] test5 = new String[7];
    String[] test6 = new String[7];
    String[] test7 = new String[7];
    String[] test8 = new String[7];
    String[] test9 = new String[7];
    String[] test10 = new String[7];
    String[] test11 = new String[7];
    String[] test12 = new String[7];

    public void TestGameInput() {
        initialiseObjects();
    }

    @BeforeSuite
    public void initialiseObjects() {
        //  Input7b
        test1[0] = "W W W B W B B";
        test1[1] = "W B W B B W B";
        test1[2] = "W W B W W B W";
        test1[3] = "B W B W B B B";
        test1[4] = "W W W B B B W";
        test1[5] = "W B - B B W B";
        test1[6] = "W B W B W B W";

        // Input7d
        test2[0] = "W B B B B W B";
        test2[1] = "W B B W B W W";
        test2[2] = "B W B B W B W";
        test2[3] = "W B W W W W W";
        test2[4] = "- W W B B B B";
        test2[5] = "B W B W W W W";
        test2[6] = "W W B B B B B";

        // Input 7i
        test3[0] = "B W - - W - B";
        test3[1] = "B - W W B B B";
        test3[2] = "B W W B - B W";
        test3[3] = "B B - - B W W";
        test3[4] = "- W - B W W B";
        test3[5] = "B - B W W W W";
        test3[6] = "- W B W B W B";

        // Input 7w
        test4[0] = "B W B B W W B";
        test4[1] = "W B W B W W W";
        test4[2] = "W B B W W W B";
        test4[3] = "W B W B W W B";
        test4[4] = "B B B W W B B";
        test4[5] = "B B W W W B B";
        test4[6] = "B B W W B W -";

        // Black: 3
        // White: 1
        // Winner: black
        test5[0] = "W B B B B W B";
        test5[1] = "W B B B B B W";
        test5[2] = "B W B W B B W";
        test5[3] = "W W W W W B W";
        test5[4] = "W - B W B W B";
        test5[5] = "B W B B W B W";
        test5[6] = "W B B B W B W";

        // Black: 2
        // White: 5
        // Winner: White
        test6[0] = "B B W B W B B";
        test6[1] = "B B W W W B W";
        test6[2] = "W W B B W W W";
        test6[3] = "W B B B W W W";
        test6[4] = "B W B W W B -";
        test6[5] = "W B B B W W B";
        test6[6] = "W B B W W W W";

        // Black: 2
        // White:  1
        // Winner:  Black
        test7[0] = "B W B B W B W";
        test7[1] = "W B W B W W W";
        test7[2] = "B B W W W W B";
        test7[3] = "B B W W B B W";
        test7[4] = "W B B B B - W";
        test7[5] = "W W B B W W W";
        test7[6] = "B W B W B B W";

        // Black: 5
        // White: 3
        // Winner: Black
        test8[0] = "B - B B W W B";
        test8[1] = "B B B B W B W";
        test8[2] = "B B W W W B W";
        test8[3] = "B W B B B W B";
        test8[4] = "B W B B W W B";
        test8[5] = "B B W W W W B";
        test8[6] = "W W W W B W B";

        // Black: 1
        // White: 2
        // Winner: White
        test9[0] = "B W B W B W W";
        test9[1] = "B W W B B B W";
        test9[2] = "W B - W B W W";
        test9[3] = "W W W W B W B";
        test9[4] = "B B B W B B W";
        test9[5] = "B W W W B W W";
        test9[6] = "W W B B W W B";

        // Black: 4
        // White: 10
        // Winner: White
        test10[0] = "W W W W W B W";
        test10[1] = "W W W W B B B";
        test10[2] = "W W W B B B W";
        test10[3] = "W W B B W B B";
        test10[4] = "W B B W W B B";
        test10[5] = "W W B W W W W";
        test10[6] = "B B - B W B W";

        // Black: 5
        // White:  1
        // Winner: Black
        test11[0] = "W B W W B B B";
        test11[1] = "B W W B W W W";
        test11[2] = "W B B B B B W";
        test11[3] = "W B W B B W W";
        test11[4] = "B B W B W W B";
        test11[5] = "B W B W W W W";
        test11[6] = "B B B B B B -";

        // Black: 1
        // White:  11
        // Winner:  White
        test12[0] = "- B W W W W B";
        test12[1] = "B B W B B W W";
        test12[2] = "W W B B B B B";
        test12[3] = "B W W W W W B";
        test12[4] = "B W W B W W W";
        test12[5] = "W W W W W B B";
        test12[6] = "W W W W W W W";
    }

    @Test
    public void testBlack() throws FiarException {
        Game b1 = new Game(new GameInput(7, test1).inputGame());
        Assert.assertEquals(b1.getWinner(), FiarGame.BLACK);
    }

    @Test
    public void testBlackBlackCount() throws FiarException {
        Game b1 = new Game(new GameInput(7, test1).inputGame());
        Assert.assertEquals(b1.getBlackWins(), 4);
    }

    @Test
    public void testBlackWhiteCount() throws FiarException {
        Game b1 = new Game(new GameInput(7, test1).inputGame());
        Assert.assertEquals(b1.getWhiteWins(), 1);
    }

    @Test
    public void testDraw() throws FiarException {
        Game b2 = new Game(new GameInput(7, test2).inputGame());
        Assert.assertEquals(b2.getWinner(), FiarGame.DRAW);
    }

    @Test
    public void testDrawBlackCount() throws FiarException {
        Game b2 = new Game(new GameInput(7, test2).inputGame());
        Assert.assertEquals(b2.getBlackWins(), 3);
    }

    @Test
    public void testDrawWhiteCount() throws FiarException {
        Game b2 = new Game(new GameInput(7, test2).inputGame());
        Assert.assertEquals(b2.getWhiteWins(), 3);
    }

    @Test
    public void testNone() throws FiarException {
        Game b3 = new Game(new GameInput(7, test3).inputGame());
        Assert.assertEquals(b3.getWinner(), FiarGame.NONE); // TODO: Functionality does not currently exist... oops :$
    }

    @Test
    public void testNoneBlackCount() throws FiarException {
        Game b3 = new Game(new GameInput(7, test3).inputGame());
        Assert.assertEquals(b3.getBlackWins(), 2);
    }

    @Test
    public void testNoneWhiteCount() throws FiarException {
        Game b3 = new Game(new GameInput(7, test3).inputGame());
        Assert.assertEquals(b3.getWhiteWins(), 4);
    }

    @Test
    public void testWhite() throws FiarException {
        Game b4 = new Game(new GameInput(7, test4).inputGame());
        Assert.assertEquals(b4.getWinner(), FiarGame.WHITE);
    }

    @Test
    public void testWhiteBlackCount() throws FiarException {
        Game b4 = new Game(new GameInput(7, test4).inputGame());
        Assert.assertEquals(b4.getBlackWins(), 5);
    }

    @Test
    public void testWhiteWhiteCount() throws FiarException {
        Game b4 = new Game(new GameInput(7, test4).inputGame());
        Assert.assertEquals(b4.getWhiteWins(), 7);
    }

    @Test
    public void test5() throws FiarException {
        Game g = new Game(new GameInput(7, test5).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.BLACK);
        Assert.assertEquals(g.getBlackWins(), 4);
        Assert.assertEquals(g.getWhiteWins(), 3);
    }

    @Test
    public void test6() throws FiarException {
        Game g = new Game(new GameInput(7, test6).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.WHITE);
        Assert.assertEquals(g.getBlackWins(), 2);
        Assert.assertEquals(g.getWhiteWins(), 5);
    }

    @Test
    public void test7() throws FiarException {
        Game g = new Game(new GameInput(7, test7).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.BLACK);
        Assert.assertEquals(g.getBlackWins(), 4);
        Assert.assertEquals(g.getWhiteWins(), 3);
    }

    @Test
    public void test8() throws FiarException {
        Game g = new Game(new GameInput(7, test8).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.BLACK);
        Assert.assertEquals(g.getBlackWins(), 5);
        Assert.assertEquals(g.getWhiteWins(), 4);
    }

    @Test
    public void test9() throws FiarException {
        Game g = new Game(new GameInput(7, test9).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.WHITE);
        Assert.assertEquals(g.getBlackWins(), 1);
        Assert.assertEquals(g.getWhiteWins(), 2);
    }

    @Test
    public void test10() throws FiarException {
        Game g = new Game(new GameInput(7, test10).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.WHITE);
        Assert.assertEquals(g.getBlackWins(), 3);
        Assert.assertEquals(g.getWhiteWins(), 8);
    }

    @Test
    public void test11() throws FiarException {
        Game g = new Game(new GameInput(7, test11).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.BLACK);
        Assert.assertEquals(g.getBlackWins(), 5);
        Assert.assertEquals(g.getWhiteWins(), 2);
    }

    @Test
    public void test12() throws FiarException {
        Game g = new Game(new GameInput(7, test12).inputGame());
        Assert.assertEquals(g.getWinner(), FiarGame.WHITE);
        Assert.assertEquals(g.getBlackWins(), 1);
        Assert.assertEquals(g.getWhiteWins(), 11);
    }
}


